home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ansi / hercules.zip / HERCPIXL.DC < prev    next >
Text File  |  1986-09-05  |  3KB  |  118 lines

  1. /*
  2.  *    HERCPIXL.C
  3.  *    Dave Tutelman  -  last modified 8/86
  4.  *
  5.  *    This is a set of basic graphic routines for the Hercules
  6.  *    Board (or at least the SuperComputer version of it; I assume
  7.  *     that they work with the real thing).
  8.  *        alfa ()        puts us in alphanumeric mode.
  9.  *        grafix (page)    puts us in graphics mode in page 0 or 1
  10.  *        pixel (x,y,val)    puts a pixel at <x,y>. Bright dot if
  11.  *                val=1, dark dot if val=0.
  12.  *         dchar (x,y,c)    puts character "c" at <x,y>. Note that
  13.  *                character raster is 90 x 29.
  14.  *        swpage (page)    switches to a different page.
  15.  *            waitkey ()    just waits till a key is pressed.
  16.  *
  17.  *    Actually, the routines should work with any board, since the
  18.  *    BIOS calls are used throughout.  It's Hercules-specific only
  19.  *    because I've defined the graphics and alpha modes for my
  20.  *    Hercules BIOS.
  21.  *
  22.  *    Compile with deSmet C.
  23.  */
  24.  
  25. #define VIDI    0x10        /* video interrupt, normally 10H  */
  26. #define    KBD    0x16        /* keyboard interrupt */
  27. #define ALFA_MODE    7    /* monochrome alpha mode */
  28. #define GRAF_MODE    8    /* Hercules graphics mode */
  29.  
  30. int    page = 0;
  31. extern unsigned _rax,_rbx,_rcx,_rdx;
  32.  
  33. /*
  34.  * This puts us back in alphanumeric mode 
  35.  */
  36.  
  37. alfa (dummy)
  38.     unsigned int dummy;
  39. {
  40.     _rax = ALFA_MODE;    /* mono 80-col mode */
  41.     _doint ( VIDI );    /* set mode */
  42. }
  43.  
  44. /*
  45.  *    This one switches us to hercules graphics mode
  46.  *        in page 0 or 1
  47.  */
  48.  
  49. grafix (newpage)
  50.     int newpage;
  51. {
  52.  
  53.     _rax = GRAF_MODE;            /* herc grafix mode */
  54.     _doint ( VIDI );    /* set mode */
  55.  
  56.     /*  now set the page */
  57.     swpage (newpage);
  58. }
  59.  
  60. /*
  61.  *   This writes a pixel at (x,y), where (0,0) is the upper-left
  62.  *   corner of the screen.  If val = 0 then the pixel is erased.
  63.  */
  64.  
  65. pixel (x, y, val)
  66.     int x, y, val;
  67. {
  68.  
  69.     _rax = 0x0C00 + val;    /* function 12      */    
  70.     _rcx = x;
  71.     _rdx = y;
  72.     _doint ( VIDI );    /* set mode */
  73.  
  74. }
  75.  
  76.  
  77. /*
  78.  *    dchar (x,y,c)    puts character "c" at <x,y>. Note that
  79.  *            character raster is 90 x 25.
  80.  */
  81.  
  82. dchar (x,y,c)
  83.     int x,y;
  84.     char c;
  85. {
  86.  
  87.     _rax = 2*256;        /* AH=Fn#2 */
  88.     _rdx = 256*y + x;        /* DH=row, DX=col */
  89.     _rbx = page * 256;        /* BH=page  */
  90.     _doint (VIDI);        /* set cursor */
  91.  
  92.     _rax = 10*256 + (int) c;    /* AH=Fn#10, AL=char */
  93.     _rbx = page * 256;        /* BH=page */
  94.     _rcx = 1;            /* CX=count */
  95.     _doint (VIDI);        /* write character */
  96. }
  97.  
  98.  
  99. /*
  100.  *    This one switches us to a different page, without changing
  101.  *    the contents of that page.
  102.  */
  103.  
  104. swpage (newpage)
  105.     int     newpage;
  106. {
  107.     page = newpage;
  108.     _rax = 0x500 + page;        /* new page function */
  109.     _doint ( VIDI );    /* interrupt call */
  110. }
  111.  
  112.  
  113. waitkey ()
  114. {
  115.     _rax = 0;        /* keyboard blocking read function */
  116.     _doint (KBD);
  117. }
  118.